﻿        using MediatR;
using System.WXT.Infrstructre.Interface;
using System.WXT.WebAPI.Application.Command.productionPickingCommand;

namespace System.WXT.WebAPI.Application.CommandHandlers.productionPickingCommandHandlers
{
    public class productionPickingAddCommandHandlers:IRequestHandler<productionPickingAddCommand,int>
    {
        protected readonly IproductionPickingRepository iproductionPickingRepository;

        public productionPickingAddCommandHandlers(IproductionPickingRepository iproductionPickingRepository)
        {
            this.iproductionPickingRepository = iproductionPickingRepository;
        }
        /// <summary>
        /// 生产领料添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<int> Handle(productionPickingAddCommand request, CancellationToken cancellationToken)
        {
            var res = request.productionPickingDate.Value.ToUniversalTime();
            var list = await iproductionPickingRepository.Add(new Domain.productionPicking { productionPickingName=request.productionPickingName, productionPickingNumbering=request.productionPickingNumbering, productionPickingDate = res, productionPickingPerson = request.productionPickingPerson, TicketsName = request.TicketsName, TicketsNumbering = request.TicketsNumbering, productionPickingTaskName = request.productionPickingTaskName, productionPickingTaskNumbering = request.productionPickingTaskNumbering, craftManageName = request.craftManageName, processName = request.processName, productionPickingRemark = request.productionPickingRemark, productionPickingTotal = request.productionPickingTotal });
            return list;
        }
    }
}
